package myschool.array.homework;

import java.util.Arrays;

public class CharacterSorting {
    /**
     * 创建数组存储原字符序列
     * 利用Arrays类的sort( )方法对数组进行排序，并循环输出
     * 从最后一个元素开始，将数组中的元素逆序输出
     * @param args
     */
    public static void main(String[] args){
        char[]  character= {'a','c','u','b','e','p','f','z'};
        System.out.println("原排序");
        for (int i = 0; i < character.length; i++) {
            System.out.print(character[i]+"\t");
        }
        System.out.println("");
        Arrays.sort(character);
        System.out.println("升序排序");
        for (int i = 0; i < character.length; i++) {
            System.out.print(character[i]+"\t");
        }
        System.out.println("");

        System.out.println("降序排序");
        for (int i = character.length-1; i >= 0 ; i--) {
            System.out.print(character[i]+"\t");
        }



    }
}
